/* $VER: AutoSearch 2.4 (21.2.98) by Gabriele Favrin (favrin@tin.it) */ options results parse ARG args parse SOURCE . . called . domain = ".com" cfg = findpath(called)||"autosearch.cfg" multi = 1 eol = '0A'x servercfg = "" server = 1 s.1.url="http://altavista.digital.com/cgi-bin/query?pg=q&q=" s.1.name="AltaVista" s.2.url="http://www-english.lycos.com/cgi-bin/pursuit?cat=lycos&mtemp=lite&terse=&query=" s.2.name="Lycos" s.3.url="http://search.yahoo.com/bin/search?p=" s.3.name="Yahoo" s.4.url="http://www.excite.com/search.gw?search=" s.4.name="Excite" s.5.url="http://www.nlsearch.com/nlquery.fcg?sb=Search&si=&us=025&cc=&qr=" s.5.name="Northern Light" If (args == "") | (args == "%3F") then do If Exists(cfg) then do Call LoadCFG() end else do s.1.use=1 end Call CreateHTMLCFG() Call SendToAWeb('T:autosearchCFG.html') end else do If Left(args, 1) == "." then do Call ParseACFG() Call SaveCFG() end else do If Exists(cfg) then do Call LoadCFG() End else do s.1.use=1 End If Left(args, 1) == "@" then do url='http://www.'Right(args, Length(args)-1)||domain 'UrlField SET' url 'Open "'url'"' end else do Call DoSearch() end end end exit 0 ParseACFG: fp=Pos(' ', args)-1 interpret SubStr(args, 2, fp) sp=Pos('server', args) If sp ~= 0 then do multi=0 do while (sp ~= 0) interpret SubStr(args, sp, 11) s.server.use=1 servercfg=servercfg||server||eol multi=multi+1 sp=Pos('server', args, sp+10) end end else do interpret Right(args, Length(args)-1) multi=1 servercfg="1"||eol end return CreateHTMLCFG: ct=1 html='AutoSearch configuration page
Domain for default name completion

(eg. .com , .it , .nl)
Search Engines:
' return SendToAWeb: parse ARG file If Open(fp, file, 'W') then do Call WriteLN(fp, html) Call Close(fp) 'AllowCMD' 'Open file:///'file' RELOAD' 'Wait file:///'file 'UrlField SET "AutoSearch 2.4"' address command 'Delete >NIL: QUIET "'file'"' end else do 'Request "AutoSearch" "Can''t create temporary file." "_Ok" NOWAIT' end return LoadCFG: If Open(fp, cfg, 'R') then do domain=ReadLN(fp) multi=ReadLN(fp) do ct=1 to multi server=ReadLN(fp) s.server.use=1 end Call Close(fp) end else do 'Request "AutoSearch" "Can''t read configuration" "_Ok" NOWAIT' end return SaveCFG: If Open(fp, cfg, 'W') then do Call WriteCH(fp, domain||eol||multi||eol||servercfg) end else do 'Request "AutoSearch" "Can''t save configuration" "_Ok" NOWAIT' end return DoSearch: searchtext=args If (multi == 1) then do 'Open "'s.server.url||searchtext'" RELOAD' end else do 'Get ACTIVEPORT VAR' port tempfile="t:autosearch."Right(port, Length(port)-Pos('.', port))".html" ct=1 html="Search results for ""args""" 'GetCFG FRAMES VAR' frames If frames then do html=html||'
' server_html="" head_html="" do while s.ct.name ~== "S."ct".NAME" If (s.ct.use == 1) then do head_html=head_html||''s.ct.name' results   ' server_html=server_html||'

Back to top' end ct=ct+1 end html=html||head_html||server_html||'

'head_html'

' end else do head_html="" server_html="

Search ""args"" on:

' end Call SendToAWeb(tempfile) end return findpath: procedure parse ARG pathf dir_pos = Max(lastpos('/', pathf), lastpos(':', pathf)) If dir_pos > 0 then return(left(pathf,dir_pos)) else return('')